<?php

/**
 * Application form base class.
 *
 * @method Application getObject() Returns the current form's model object
 *
 * @package    wills
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 24171 2009-11-19 16:37:50Z Kris.Wallsmith $
 */
abstract class BaseApplicationForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'            => new sfWidgetFormInputHidden(),
      'email'         => new sfWidgetFormInputText(),
      'password'      => new sfWidgetFormInputText(),
      'area_id'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('area'), 'add_empty' => false)),
      'name'          => new sfWidgetFormInputText(),
      'name_en'       => new sfWidgetFormInputText(),
      'age'           => new sfWidgetFormInputText(),
      'minzu'         => new sfWidgetFormInputText(),
      'height'        => new sfWidgetFormInputText(),
      'weight'        => new sfWidgetFormInputText(),
      'bwh'           => new sfWidgetFormInputText(),
      'occupation'    => new sfWidgetFormInputText(),
      'education'     => new sfWidgetFormInputText(),
      'college'       => new sfWidgetFormInputText(),
      'address'       => new sfWidgetFormInputText(),
      'id_card'       => new sfWidgetFormInputText(),
      'phone'         => new sfWidgetFormInputText(),
      'qq'            => new sfWidgetFormInputText(),
      'website'       => new sfWidgetFormInputText(),
      'native_place'  => new sfWidgetFormInputText(),
      'contact'       => new sfWidgetFormInputText(),
      'relation'      => new sfWidgetFormInputText(),
      'contact_phone' => new sfWidgetFormInputText(),
      'introduction'  => new sfWidgetFormTextarea(),
      'hobby'         => new sfWidgetFormTextarea(),
      'watchword'     => new sfWidgetFormTextarea(),
      'picture'       => new sfWidgetFormInputText(),
      'picturelife'   => new sfWidgetFormInputText(),
      'is_passed'     => new sfWidgetFormInputCheckbox(),
      'created_at'    => new sfWidgetFormDateTime(),
      'updated_at'    => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'            => new sfValidatorDoctrineChoice(array('model' => $this->getModelName(), 'column' => 'id', 'required' => false)),
      'email'         => new sfValidatorString(array('max_length' => 255)),
      'password'      => new sfValidatorString(array('max_length' => 40)),
      'area_id'       => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('area'))),
      'name'          => new sfValidatorString(array('max_length' => 255)),
      'name_en'       => new sfValidatorString(array('max_length' => 255)),
      'age'           => new sfValidatorInteger(),
      'minzu'         => new sfValidatorString(array('max_length' => 255)),
      'height'        => new sfValidatorString(array('max_length' => 255)),
      'weight'        => new sfValidatorString(array('max_length' => 255)),
      'bwh'           => new sfValidatorString(array('max_length' => 255)),
      'occupation'    => new sfValidatorString(array('max_length' => 255)),
      'education'     => new sfValidatorString(array('max_length' => 255)),
      'college'       => new sfValidatorString(array('max_length' => 255)),
      'address'       => new sfValidatorString(array('max_length' => 255)),
      'id_card'       => new sfValidatorString(array('max_length' => 255)),
      'phone'         => new sfValidatorString(array('max_length' => 255)),
      'qq'            => new sfValidatorString(array('max_length' => 255)),
      'website'       => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'native_place'  => new sfValidatorString(array('max_length' => 255)),
      'contact'       => new sfValidatorString(array('max_length' => 255)),
      'relation'      => new sfValidatorString(array('max_length' => 255)),
      'contact_phone' => new sfValidatorString(array('max_length' => 255)),
      'introduction'  => new sfValidatorString(array('max_length' => 1000)),
      'hobby'         => new sfValidatorString(array('max_length' => 500)),
      'watchword'     => new sfValidatorString(array('max_length' => 500)),
      'picture'       => new sfValidatorString(array('max_length' => 255)),
      'picturelife'   => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'is_passed'     => new sfValidatorBoolean(array('required' => false)),
      'created_at'    => new sfValidatorDateTime(),
      'updated_at'    => new sfValidatorDateTime(),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorAnd(array(
        new sfValidatorDoctrineUnique(array('model' => 'Application', 'column' => array('email'))),
        new sfValidatorDoctrineUnique(array('model' => 'Application', 'column' => array('id_card'))),
      ))
    );

    $this->widgetSchema->setNameFormat('application[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Application';
  }

}
